package plgigiel.behaviour.boid;

import pl.gigiel.behaviour.IBoid;
import pl.gigiel.behaviour.IBoidFeatures;
import pl.gigiel.behaviour.util.Util;

import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;

public class BoidFeatures implements IBoidFeatures {
	private String id;
	private float mass;
	private Vector3f size;
	private ColorRGBA color;
	private float agility;
	private float speed;
	private float stamina;
	private Vector3f position;
	private Vector3f velocity;
	private Vector3f direction;
	private IBoid targetBoid;
	private Vector3f targetPoint;
	private IBoid antiTargetBoid;
	private Vector3f antiTargetPoint;

	@Override
	public String getId() {
		return new String(id);
	}

	@Override
	public void setId(String id) {
		this.id = new String(id);
	}

	@Override
	public float getMass() {
		return mass;
	}

	@Override
	public void setMass(float mass) {
		this.mass = mass;
	}

	@Override
	public Vector3f getSize() {
		return Util.cloneVector(size);
	}

	@Override
	public void setSize(Vector3f size) {
		this.size = Util.cloneVector(size);
	}

	@Override
	public ColorRGBA getColor() {
		return new ColorRGBA(color);
	}

	@Override
	public void setColor(ColorRGBA color) {
		this.color = new ColorRGBA(color);
	}

	@Override
	public float getAgility() {
		return agility;
	}

	@Override
	public void setAgility(float agility) {
		this.agility = agility;
	}

	@Override
	public float getSpeed() {
		return speed;
	}

	@Override
	public void setSpeed(float speed) {
		this.speed = speed;
	}

	@Override
	public float getStamina() {
		return stamina;
	}

	@Override
	public void setStamina(float stamina) {
		this.stamina = stamina;
	}

	@Override
	public Vector3f getPosition() {
		return Util.cloneVector(position);
	}

	@Override
	public void setPosition(Vector3f position) {
		this.position = Util.cloneVector(position);
	}

	@Override
	public Vector3f getVelocity() {
		return Util.cloneVector(velocity);
	}

	@Override
	public void setVelocity(Vector3f velocity) {
		this.velocity = Util.cloneVector(velocity);
		this.direction = velocity.normalize();
	}

	@Override
	public Vector3f getDirection() {
		return Util.cloneVector(direction);
	}

	@Override
	public IBoid getTargetBoid() {
		return targetBoid;
	}

	@Override
	public void setTargetBoid(IBoid targetBoid) {
		this.targetBoid = targetBoid;
	}

	@Override
	public Vector3f getTargetPoint() {
		return Util.cloneVector(targetPoint);
	}

	@Override
	public void setTargetPoint(Vector3f targetPoint) {
		this.targetPoint = Util.cloneVector(targetPoint);
	}

	@Override
	public IBoid getAntiTargetBoid() {
		return antiTargetBoid;
	}

	@Override
	public void setAntiTargetBoid(IBoid antiTargetBoid) {
		this.antiTargetBoid = antiTargetBoid;
	}

	@Override
	public Vector3f getAntiTargetPoint() {
		return Util.cloneVector(antiTargetPoint);
	}

	@Override
	public void setAntiTargetPoint(Vector3f antiTargetPoint) {
		this.antiTargetPoint = Util.cloneVector(antiTargetPoint);
	}

	@Override
	public IBoidFeatures clone() {
		BoidFeatures result = new BoidFeatures();

		result.setId(new String(id));
		result.setMass(mass);
		result.setSize(Util.cloneVector(size));
		result.setColor(new ColorRGBA(color));
		result.setAgility(agility);
		result.setSpeed(speed);
		result.setStamina(stamina);
		result.setPosition(Util.cloneVector(position));
		result.setVelocity(Util.cloneVector(velocity));
		result.setTargetBoid(targetBoid);
		result.setTargetPoint(Util.cloneVector(targetPoint));
		result.setAntiTargetBoid(antiTargetBoid);
		result.setAntiTargetPoint(Util.cloneVector(antiTargetPoint));

		return result;
	}
}
